package com.xtck.ha.system.api.factory;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.xtck.ha.common.core.domain.R;
import com.xtck.ha.common.domain.system.api.HisTelemetryParam;
import com.xtck.ha.system.api.RemoteHealthDataService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author zhouss
 * @date 2024/11/21
 **/
@Component
public class RemoteHealthDataFallBackFactory implements FallbackFactory<RemoteHealthDataService> {
    @Override
    public RemoteHealthDataService create(Throwable throwable) {
        return new RemoteHealthDataService() {
            @Override
            public R<JSONObject> getSpinner() {
                return R.fail("获取预处理方法列表失败:" + throwable.getMessage());
            }

            @Override
            public R<JSONArray> manualCalculation(HisTelemetryParam hisTelemetryParam) {
                return R.fail("获取原始遥测参数数据失败:" + throwable.getMessage());
            }
        };
    }
}
